public class Demo {
    public static int Test(int head,int tail){
        int mun = 0;
        for (int i = head; i <= tail; i++) {
            int demo = i;
            while (demo != 0){
                if (demo % 10 == 2){
                    mun++;
                }
                demo = demo/10;
            }
        }
        return mun;
    }

    public static void main(String[] args) {
        int a = 2;
        int b = 22;
        int test = Test(a,b);
        System.out.println(test);
    }
}
